﻿Imports extranet.BE
Imports extranet.BC
Imports MetodosComuns

Partial Class forum_adm_editar_categoria
    Inherits System.Web.UI.Page
    Dim objBEForum As BEForum
    Dim strid As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim strTela As String = MetodosComuns.GetCurrentPageName()
        Dim objBESeguranca As New BESeguranca
        Dim objBEUsuario As BEUsuario = Session("objBEUsuario")

        If IsNothing(objBEUsuario) Then Response.Redirect(TELA_LOGOUT)
        Session("strTela") = MetodosComuns.GetCurrentPageName()
        If Not IsPostBack Then          ' SEGURANÇA
            objBESeguranca = BCSeguranca.SelecionaPermissoes(objBEUsuario.GrupoAcesso, Session("strTela"))
            If Not objBESeguranca.Autorizado Then Response.Redirect(TELA_LOGOUT)
            Session("objBESeguranca") = objBESeguranca
        Else
            objBESeguranca = Session("objBESeguranca")
        End If

        If objBESeguranca.Escrita Then 'Verificar aki se usuário tem permissao de administrador
            If Not IsPostBack Then
                objBEForum = New BEForum
                strid = Request.QueryString("id")
                objBEForum = BCForum.SelecionaCategoria(strid)

                txtNome.Text = objBEForum.Nome
                If objBEForum.Visivel Then
                    DropDownList1.SelectedIndex = 1
                Else
                    DropDownList1.SelectedIndex = 0
                End If
            End If
        Else
            Response.Redirect(TELA_LOGOUT)
        End If
    End Sub

    Protected Sub btnCancelar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancelar.Click
        Response.Redirect("forum_inicial.aspx")
    End Sub

    Protected Sub btnGravar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGravar.Click
        objBEForum = New BEForum

        strid = Request.QueryString("id")
        objBEForum.Id = strid
        objBEForum.Nome = txtNome.Text
        If DropDownList1.SelectedIndex = 1 Then
            objBEForum.Visivel = True
        Else
            objBEForum.Visivel = False
        End If
        BCForum.AlteraCategoria(objBEForum)
        Response.Redirect("forum_inicial.aspx")
    End Sub
End Class
